package com.itheima;

import java.util.Scanner;

public class Java_04 {
    public static void main(String[] args) {
        double rs = score(10);
        System.out.println("成绩是："+ rs);
    }
    //案例练习三：评委打分
    public static double score(int n){
        int[] scores = new int[n];
        Scanner sc = new Scanner(System.in);
        //定义变量。分别接收打分的最大值，最小值，总分
        int max = 0;
        int min = 0;
        int sum = 0;

        for (int i = 0; i < scores.length; i++) {
            //让用户输入评委打的分数
            System.out.println("请输入第"+(i + 1)+"个评委打的分数:");
            int num = sc.nextInt();
            scores[i] = num;
        }
        //遍历这个数组，找出最大值，最小值，并求和
        for (int i = 0; i < scores.length; i++) {
            if (scores[i] > max){
                max = scores[i];
            }
            if (scores[i] < min){
                min = scores[i];
            }
            sum += scores[i];
        }
        double score = 1.0 * (sum - max - min) / (scores.length-2);
        return score;
    }
}
